package com.platform.hjt.erp.service;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.platform.hjt.base.controller.ReturnBody;
import com.platform.hjt.base.service.BaseService;
import com.platform.hjt.erp.dao.ErpGoodInfoDAO;
import com.platform.hjt.erp.model.ErpGoodInfo;
import com.hjt.tools.dao.Page;
import com.hjt.tools.dao.PropertyFilter;
import com.hjt.tools.date.DateCreator;

@Service
public class ErpGoodInfoService extends BaseService{

	@Resource
	private ErpGoodInfoDAO erpGoodInfoDAO;
	
	public ReturnBody saveErpGoodInfo(ErpGoodInfo erpGoodInfo){
		if(StringUtils.isNotBlank(erpGoodInfo.getErpGoodInfoId())){
			erpGoodInfoDAO.updatePerproties(erpGoodInfo);
			return  new ReturnBody(true, "更新成功");
		}else{
			erpGoodInfo.setCreateTime(DateCreator.getCurrentTime());
			erpGoodInfo.setIsDel(false);
			erpGoodInfo.setSysCompanyInfo(getSessionSysCompanyInfo());
			erpGoodInfoDAO.saveJ(erpGoodInfo);
			return  new ReturnBody(true, "添加成功");
		}
	}
	
	public ReturnBody delErpGoodInfo(ErpGoodInfo erpGoodInfo){
		erpGoodInfo.setIsDel(true);
		erpGoodInfoDAO.updatePerproties(erpGoodInfo);
		return  new ReturnBody(true, "删除成功");
	}
	
	public Page<ErpGoodInfo> getErpGoodInfoList(Page<ErpGoodInfo> page, List<PropertyFilter> propertyFilterList){
		return erpGoodInfoDAO.findPage(page, propertyFilterList);
	}
	
	public List<ErpGoodInfo> getErpGoodInfoList(List<PropertyFilter> filters){
		return erpGoodInfoDAO.find(filters);
	}
	
	public ErpGoodInfo getErpGoodInfo(List<PropertyFilter> filters){
		return erpGoodInfoDAO.findUniqueBy(filters);
	}
	
	public ErpGoodInfo getErpGoodInfo(String propertyName, Object value){
		return erpGoodInfoDAO.findUniqueBy(propertyName, value);
	}
	
}
